<template>
  <div class="movie-list">
    <div class="list">
      <router-link class="item" v-for="item in coming" :key="item.id" to="">
        <div class="bg">
          <div class="default-img-bg">
            <img :src="$options.filters.src(item.img)" />
          </div>
        </div>
        <div class="info">
          <div class="content">
            <div class="title">
              <span class="name">{{ item.nm }}</span>
            </div>
            <div class="detail">
              <div class="line-ellipsis">
                <span class="person">{{ item.wish }}</span>
                <span class="p-suffix">人想看</span>
              </div>
            </div>

            <div class="line-ellipsis">主演：{{ item.star }}</div>
            <div class="line-ellipsis">{{ item.rt }}上映</div>
          </div>
          <div class="button-block" v-if="item && item.showStateButton">
            <router-link :to="`/buyinfo/${item.id}`">
              <div
                class="btn"
                :style="{ background: item.showStateButton.color }"
              >
                <span>{{ item.showStateButton.content }}</span>
              </div>
            </router-link>
          </div>
        </div>
      </router-link>
    </div>
  </div>
</template>

<script>
export default {
  props:["coming"],
  filters: {
    src(value) {
      return value.replace("w.h", "100.138");
    },
  },
};
</script>

<style lang="less" scoped>
.list {
  display: flex;
  flex-direction: column;
  background-color: #f5f5f5;

  .item {
    position: relative;
    padding-left: 15px;
    background-color: #fff;

    .bg {
      margin-top: 12px;
      width: 64px;
      height: 95px;
      position: relative;
      float: left;

      img {
        background-color: transparent;
        height: 90px;
        width: 65px;
      }

      &::before {
        content: "";
        display: block;
        position: absolute;
        width: 48px;
        height: 48px;
        background-repeat: no-repeat;
        background-size: contain;
      }
    }

    .info {
      padding: 12px 18px 12px 0;
      margin-left: 74px;
      height: 90px;
      max-height: 90px;
      position: relative;

      .content {
        margin-right: 48px;
        padding-right: 5px;
        overflow: hidden;
      }

      .button-block {
        position: absolute;
        right: 14px;
        top: 0;
        bottom: 0;
        height: 27px;
        margin: auto;

        .btn {
          width: 54px;
          height: 28px;
          display: flex;
          justify-content: center;
          align-items: center;
          box-sizing: border-box;
          background-color: #f03d37;
          color: #fff;
          white-space: nowrap;
          font-size: 13px;
          font-weight: 500;
          cursor: pointer;
          border-radius: 14px;
        }
      }

      .title {
        max-height: 24px;
        margin-bottom: 7px;
        line-height: 24px;
        overflow: hidden;

        .name {
          font-size: 17px;
          font-weight: 700;
          padding-right: 5px;
          flex-shrink: 1;
          color: #333;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        }
      }
      .detail {
        box-sizing: border-box;
        line-height: 1;
        overflow: hidden;
        .line-ellipsis {
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          .person {
            color: #faaf00;
            font-size: 15px;
            font-weight: 600;
          }
          .p-suffix {
            font-size: 13px;
            margin-left: -2px;
            display: inline-block;
            color: #666;
          }
        }
      }
      .line-ellipsis {
        font-size: 13px;
        color: #666;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
    }
  }
}
</style>